package com.example.activiti.service.impl;

import com.example.activiti.common.utils.DateUtils;
import com.example.activiti.common.utils.SecurityUtils;
import com.example.activiti.domain.ActWorkflowFormData;
import com.example.activiti.mapper.ActWorkflowFormDataMapper;
import com.example.activiti.service.IActWorkflowFormDataService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;


/**
 * 动态单Service业务层处理
 *
 * @author danny
 * @date 2020-11-02
 */
@Service
public class ActWorkflowFormDataServiceImpl implements IActWorkflowFormDataService {

    @Resource
    private ActWorkflowFormDataMapper actWorkflowFormDataMapper;

    /**
     * 查询动态单
     *
     * @param id 动态单ID
     * @return 动态单
     */
    @Override
    public ActWorkflowFormData selectActWorkflowFormDataById(Long id) {
        return actWorkflowFormDataMapper.selectActWorkflowFormDataById(id);
    }

    @Override
    public List<ActWorkflowFormData> selectActWorkflowFormDataByBusinessKey(String businessKey) {
        return actWorkflowFormDataMapper.selectActWorkflowFormDataByBusinessKey(businessKey);
    }

    /**
     * 查询动态单列表
     *
     * @param actWorkflowFormData 动态单
     * @return 动态单
     */
    @Override
    public List<ActWorkflowFormData> selectActWorkflowFormDataList(ActWorkflowFormData actWorkflowFormData) {
        return actWorkflowFormDataMapper.selectActWorkflowFormDataList(actWorkflowFormData);
    }

    /**
     * 新增动态单
     *
     * @param actWorkflowFormData 动态单
     * @return 结果
     */
    @Override
    public int insertActWorkflowFormData(ActWorkflowFormData actWorkflowFormData) {
        actWorkflowFormData.setCreateTime(DateUtils.getNowDate());
        return actWorkflowFormDataMapper.insertActWorkflowFormData(actWorkflowFormData);
    }

    @Override
    public int insertActWorkflowFormDatas(String userId, String userName, List<ActWorkflowFormData> actWorkflowFormData) {
        return actWorkflowFormDataMapper.insertActWorkflowFormDatas(userId, actWorkflowFormData, new Date(), userName);
    }


    /**
     * 修改动态单
     *
     * @param actWorkflowFormData 动态单
     * @return 结果
     */
    @Override
    public int updateActWorkflowFormData(ActWorkflowFormData actWorkflowFormData) {
        return actWorkflowFormDataMapper.updateActWorkflowFormData(actWorkflowFormData);
    }

    /**
     * 批量删除动态单
     *
     * @param ids 需要删除的动态单ID
     * @return 结果
     */
    @Override
    public int deleteActWorkflowFormDataByIds(Long[] ids) {
        return actWorkflowFormDataMapper.deleteActWorkflowFormDataByIds(ids);
    }

    /**
     * 删除动态单信息
     *
     * @param id 动态单ID
     * @return 结果
     */
    @Override
    public int deleteActWorkflowFormDataById(Long id) {
        return actWorkflowFormDataMapper.deleteActWorkflowFormDataById(id);
    }
}
